package LeetCode.LeetCode2;

/**
 * 输入有序的数组
 * @author lumin
 * @date 2022/03/18 12:30
 **/
public class Num167 {
    public int[] twoSum(int[] numbers, int target) {
        int i = 0;
        int j = numbers.length - 1;
        int[] arr = new int[2];
        while(i < j){
            if(numbers[i] + numbers[j] == target){
                arr[0] = i + 1;
                arr[1] = j + 1;
                return arr;
            }else if(numbers[i] + numbers[j] > target){
                j--;
            }else{
                i++;
            }
        }
        return arr;
    }
}